{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n",
      "['花', '花开', '花']\n",
      "['花开']\n",
      "['年', '年', '年', '年', '年', '年']\n",
      "['年年', '年年']\n",
      "[]\n",
      "['年', '年', '年年', '年年']\n",
      "['年花落颜色改，明年花开复谁在？年年岁岁花相似，岁岁年年人不同。']\n",
      "['年花', '年花', '年年岁', '年年人']\n",
      "['年花落颜色改，明年花开复谁在？年年岁岁花']\n",
      "['年花', '年花']\n"
     ]
    }
   ],
   "source": [
    "import re\n",
    "text=\"今年花落颜色改，明年花开复谁在？年年岁岁花相似，岁岁年年人不同。\"\n",
    "print(re.findall('花开？',text))\n",
    "print(re.findall('花开*',text))\n",
    "print(re.findall('花开+',text))\n",
    "print(re.findall('年{1}',text))\n",
    "print(re.findall('年{2}',text))\n",
    "print(re.findall('年{2，}',text))\n",
    "print(re.findall('年{1,2}',text))\n",
    "print(re.findall('年.+',text))\n",
    "print(re.findall('年+.',text))\n",
    "print(re.findall('年.+花',text))\n",
    "print(re.findall('年.?花',text))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "我的个人网页的地址是:http\"//jiy##ui##able,邮箱是:f_####@qq.com\n",
      "#####################34##90###########9034#######\n",
      "我的个人网页的地址是:http\"//jiy34ui90able,邮箱是:f_9034@qq.com\n",
      "#################################################\n",
      "##########:####\"//#############,###:######@##.###\n",
      "##########:####\"//#############,###:######@##.###\n"
     ]
    }
   ],
   "source": [
    "import re\n",
    "text='我的个人网页的地址是:http\"//jiy34ui90able,邮箱是:f_9034@qq.com'\n",
    "print(re.sub('\\d','#',text))\n",
    "print(re.sub('\\D','#',text))\n",
    "print(re.sub('\\s','#',text))\n",
    "print(re.sub('\\S','#',text))\n",
    "print(re.sub('\\w','#',text))\n",
    "print(re.sub('\\w','#',text))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
